package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.itheima.reggie.entity.User;
import com.itheima.reggie.mapper.Usermapper;
import com.itheima.reggie.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private Usermapper usermapper;
    /**
     * 添加用户
     *
     * @param user
     */
    @Override
    public void addUser(User user) {
        usermapper.insert(user);
    }

    /**
     * 查询用户
     *
     * @param phone
     * @return
     */
    @Override
    public User findUser(String phone) {
        LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();
        lqw.eq(User::getPhone,phone);
        return usermapper.selectOne(lqw);
    }
}
